﻿<%@ Page Language="C#" MasterPageFile="~/Masters/WithoutPermBasic.Master" AutoEventWireup="true" CodeBehind="BindBottle.aspx.cs" Inherits="PMS.UI.PM.BindBottle" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        var action = com.get.action;
        //回车保存
        $(document).keyup(function (event) {
            if (event.keyCode == 13 && action == 'edit') {
                funcSave();
            }
        });
    </script>

    <script type="text/javascript">
        var SupplierName;
        var gbCode = '';
        var comboGBInit = false;
        $(function () {

            var quotDetailID = com.get.QuotDetailID;
            var action = com.get.action;
            var bottleID = com.get.ID;
            if (action == 'view') {
                $.ajax({
                    type: "POST", dataType: "json",
                    url: "/Logic/PM/BottleAnalyseAjax.aspx?method=GetBindBottleInfoByID",
                    data: { ID: bottleID },
                    success: function (data) {
                        $("#form1").form("load", data.obj);
                        $("#GBID").combogrid('setValue', data.obj.GBCode);
                        $("#PersonID").combobox('setValue', data.obj.ProdUserName);
                        $('#BottleCheckDate').datebox('setValue', data.LastCheckDate);
                        $('#BottleProdDate').datebox('setValue', data.ProductionDate);
                        $('#BottleNote').textbox('setValue', data.BottleNote);
                        $('#MadeCode').combogrid('setValue', data.MadeCode);
                        $('#BottleSupplier').textbox('setValue', data.BottleSupplier);

                    }
                })
            }
            //加载产品技术信息
            $.ajax({
                type: "POST", dataType: "json",
                url: "/Logic/CM/QuotationAjax.aspx?method=GetProductionDetailByID&Id=" + quotDetailID,
                success: function (data) {
                    $("#form1").form("load", data);
                    SupplierName = data.ComName;
                    if ("1" == data.IsPureGas) {
                        $.ajax({
                            type: "POST",
                            dataType: "json",
                            url: "/Logic/CM/QuotationAjax.aspx?method=GetProdTechAndGBInfoByID&id=" + data.ID,
                            success: function (data) {
                                $("#GBID").combogrid('setValue', data.ID);
                                $('#GasName').textbox('setValue', data.GasName);
                                $('#Range').textbox('setValue', data.Range);
                                $('#Uncertainty').textbox('setValue', data.Uncertainty);
                            }
                        })
                    }
                    else {
                        //带出相同产品的国标号
                        $.ajax({
                            type: "POST",
                            dataType: "json",
                            url: "/Logic/CM/QuotationAjax.aspx?method=GetSameGBInfoByID&id=" + data.ID,
                            success: function (data) {
                                if (data.msg == true) {
                                    $("#GBID").combogrid('setValue', data.per.ID);
                                    $('#GasName').textbox('setValue', data.per.GasName);
                                    $('#Range').textbox('setValue', data.per.Range);
                                    $('#Uncertainty').textbox('setValue', data.per.Uncertainty);
                                    $("#GBID").combogrid('setText', data.per.GBCode);
                                    gbCode = data.per.GBCode;
                                }
                            }
                        })
                    }
                }
            })

            if (action == 'edit') {
                //加载配气师下拉框
                $.ajax({
                    type: "POST", dataType: "json",
                    url: "/Logic/CommonAjax/UserRelateAjax.aspx?method=GetLoginPersonIDDepID",
                    success: function (data) {

                        $('#PersonID').combobox({
                            required: true,
                            multiple: true,
                            editable: false,
                            url: "/Logic/CommonAjax/UserRelateAjax.aspx?method=GetPersonByDepId&depID=3",
                            valueField: 'value',
                            textField: 'text'
                        });
                        if (data.depID == "3") {
                            $("#PersonID").combobox("setValue", data.id);
                        }

                    }
                })

                //加载制造代码下拉列表
                $('#MadeCode').combogrid({
                    required: false,
                    loadMsg: '检索中...',
                    panelWidth: 310,
                    pagination: true,
                    rownumbers: true,
                    idField: 'ID',
                    mode: 'remote',
                    textField: 'MadeCode',
                    url: '/Logic/BD/BottleSupplierAjax.aspx?method=GetBottleSupplierByQ',
                    columns: [[
                    { field: 'MadeCode', title: '制造代码', width: 100 },
                    { field: 'BottleSupplier', title: '生产厂家', width: 150 },
                    { field: 'Note', title: '备注', width: 50 }
                    ]],
                    onChange: function (newValue, oldValue) {
                        var g = $('#MadeCode').combogrid('grid');
                        var r = g.datagrid('getSelected');
                        if (r != null) {
                            $('#BottleSupplier').textbox('setValue', r.BottleSupplier);
                        }
                    },
                    onLoadSuccess: function (data) {

                    }
                })
                //加载国标号下拉列表
                $('#GBID').combogrid({

                    panelWidth: 650,
                    pagination: true,
                    rownumbers: true,
                    loadMsg: '检索中...',
                    idField: 'ID',
                    mode: 'remote',
                    textField: 'GBCode',
                    valueField: 'ID',
                    url: '/Logic/BD/GBAjax.aspx?method=GetGBInfoByQ',
                    columns: [[
                    { field: 'GBCode', title: '国标号', width: 160 },
                    { field: 'GasName', title: '名称', width: 200 },
                    { field: 'Range', title: '范围', width: 200 },
                    { field: 'Uncertainty', title: '不确定度（%）', width: 80 }
                    ]],
                    onChange: function (newValue, oldValue) {
                        var g = $('#GBID').combogrid('grid');
                        var r = g.datagrid('getSelected');
                        if (r != null) {
                            $('#GasName').textbox('setValue', r.GasName);
                            $('#Range').textbox('setValue', r.Range);
                            $('#Uncertainty').textbox('setValue', r.Uncertainty);
                        }
                    },
                    onLoadSuccess: function (data) {

                        if (!comboGBInit) {
                            $("#GBID").combogrid('setText', gbCode);
                            comboGBInit = true;
                        }
                    }
                })
            }


        })
    </script>

    <script type="text/javascript">
        $(function () {
            var action = com.get.action;
            if (action == 'view') {
                $('#btnSave').linkbutton('disable');
            } else {
                $('#btnSave').linkbutton('enable');
            }
        })

        //保存
        function funcSave() {
            //判断是否选择了气瓶
            var bottleCode = $('#BottleCode').textbox('getValue');
            if (bottleCode == '') {
                com.message("error", "气瓶编号不能为空！");
                return
            }
            //判断是否选择了国标
            var GBid = $('#GBID').combobox('getValue');
            if (GBid == "") {
                GBid = 0; //未填写默认为0
            }
            else if (/^\d+$/.test(GBid) == false) {
                com.message("error", "请选择正确的国标号");
                return
            }

            //添加绑定
            var madeCodeid = $('#MadeCode').combobox('getValue');
            var quotDetailID = com.get.QuotDetailID;
            var prodOrderID = com.get.ProdOrderID;
            var pressure = $('#Pressure').textbox('getValue');
            var personName = $('#PersonID').combobox('getText');
            var personID = $('#PersonID').combobox('getValues');
            var bottleCheckDate = $('#BottleCheckDate').datebox('getValue');
            var bottleProdDate = $('#BottleProdDate').datebox('getValue');
            var bottleVolume = $('#BottleVolume').textbox('getValue');
            personID = JSON.stringify(personID);
            var note = $('#BottleNote').textbox('getValue');
            var isPureGas = $('#IsPureGas').combobox('getValue');
            com.ajax({
                url: "/Logic/PM/BottleProductionAjax.aspx?method=AddBottleProductionInfo",
                data: {
                    PersonIDs: personID, IsPureGas: isPureGas, BottleCode: bottleCode, MadeCodeid: madeCodeid,
                    GBID: GBid, QuotationDetailID: quotDetailID, ProductOrderID: prodOrderID, Pressure: pressure,
                    PersonID: personName, BottleNote: note, SupplierName: SupplierName, BottleProdDate: bottleProdDate,
                    BottleCheckDate: bottleCheckDate, BottleVolume: bottleVolume
                },
                success: function (data) {
                    com.message(data.state, data.msg);
                    if (data.state == "success") {
                        //top.wrapper.tabRefresh('/UI/PM/BottleCommissionList.aspx');
                        window.location.href = "/UI/PM/GeneralAssingGas.aspx?method=assign&BarCode=" + data.returnValue;

                    }
                }
            });
        }
    </script>
</asp:Content>



<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceToorbar" runat="server">
    <a href="javascript:void(0)" id="btnSave" class="easyui-linkbutton" onclick="funcSave()"
        data-options="iconCls:'icon-save',plain:true">保存</a> &nbsp;&nbsp;

</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">
        <div id="master" class="container_12" style="height: auto">
            <form id="form1">
                <div id="title" class="grid_12" style="text-align: center">
                    <h1>产品技术信息</h1>
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    产品名称 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input type="text" id="ProductName" name="ProductName" disabled="disabled" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    规格(L) :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="BottleVolume" name="BottleVolume" disabled="disabled" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    是否新瓶 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input type="text" id="IsNewBottle" name="IsNewBottle" class="easyui-combobox"
                        data-options="valueField:'value',textField:'text',data:StaticCombo.isNewBottle,panelHeight:'auto'"
                        disabled="disabled" />
                </div>
                <div class="Clear"></div>
                <div class="grid_1 lbl" style="text-align: right;">
                    技术参数 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="TechParams" name="TechParams" data-options="multiline:true" disabled="disabled" style="height: 50px" />
                </div>

                <div class="grid_1 lbl" style="text-align: right;">
                    产品备注 :
                </div>
                <div class="grid_2 val" style="text-align: left; height: 50px">
                    <input class="easyui-textbox" id="Note" name="Note" disabled="disabled" data-options="multiline:true" style="height: 50px" />
                </div>

                <div class="grid_1 lbl" style="text-align: right;">
                    是否纯气 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input type="text" id="IsPureGas" class="easyui-combobox" name="IsPureGas"
                        data-options="valueField:'value',textField:'text',data:[{value:0,text:'否'},{value:1,text:'是'}], panelHeight:'auto'"
                        disabled="disabled" />
                </div>
                <div class="Clear"></div>

                <div class="grid_12">
                    <hr style="width: 100%; margin-left: 5px" />
                </div>
                <div id="title1" class="grid_12" style="text-align: center">
                    <h1>气瓶信息</h1>
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    气瓶编号 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="BottleCode" name="BottleCode" data-options="required:true" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    生产日期:
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-datebox" id="BottleProdDate" name="BottleProdDate" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    质检日期:
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-datebox" id="BottleCheckDate" name="BottleCheckDate" />
                </div>
                <div class="grid_3 lbl" style="text-align: right;">
                    制造代码:
                    <input class="easyui-combogrid" id="MadeCode" name="MadeCode" />
                </div>
                <div class="Clear"></div>
                <div class="grid_1 lbl" style="text-align: right;">
                    压力(MPa):
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="Pressure" name="Pressure" value="9.5" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    配气师:
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-combobox" id="PersonID" name="PersonID" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    气瓶备注:
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="BottleNote" name="BottleNote" />
                </div>
                <div class="grid_3 lbl" style="text-align: right;">
                    生产厂家 :
                    <input class="easyui-textbox" id="BottleSupplier" name="BottleSupplier" disabled="disabled" />
                </div>
                <div class="Clear"></div>
                <div class="grid_12">
                    <hr style="width: 100%; margin-left: 5px" />
                </div>
                <div id="title2" class="grid_12" style="text-align: center">
                    <h1>国标信息</h1>
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    国标号 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-combogrid" id="GBID" name="GBID" />
                </div>

                <div class="grid_1 lbl" style="text-align: right;">
                    范围 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="Range" name="Range" disabled="disabled" />
                </div>
                <div class="grid_1 lbl" style="text-align: right;">
                    不确定度:
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="Uncertainty" name="Uncertainty" disabled="disabled" />
                </div>

                <div class="grid_1 lbl" style="text-align: right;">
                    名称 :
                </div>
                <div class="grid_2 val" style="text-align: left;">
                    <input class="easyui-textbox" id="GasName" name="GasName" disabled="disabled" data-options="multiline:true" style="height: 40px" />
                </div>

                <div class="Clear"></div>
                <div class="grid_12">
                    <hr style="width: 100%; margin-left: 5px; margin-top: 5px" />
                </div>
                <div id="title3" class="grid_12" style="text-align: center">
                    <h1>充装前检查项目</h1>
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    漆色 :灰
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    瓶阀螺纹 :右
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    油污 :无
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    安全附件 :有
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    警示标签 :有
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    有无余压 :负
                </div>
                <div class="grid_2 lbl" style="text-align: left;">
                    卸压装置 :无
                </div>
                <div class="grid_2 lbl" style="text-align: left;">
                    瓶内气体性质 :惰性
                </div>
                <div class="grid_2 lbl" style="text-align: left;">
                    外表情况 :好
                </div>
                <div class="Clear"></div>
                <div class="grid_12">
                    <hr style="width: 100%; margin-left: 5px; margin-top: 5px" />
                </div>
                <div id="title4" class="grid_12" style="text-align: center">
                    <h1>充装后检查项目</h1>
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    瓶温有无异常 :无
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    有无鼓包变形 :无
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    有无泄漏 :无
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    安全附件是否齐全 :是
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    颜色标记 :
                </div>
                <div class="grid_2 sealbl" style="text-align: left;">
                    检验色标 :
                </div>
                <div class="grid_2 lbl" style="text-align: left;">
                    取样分析是否合格 :是
                </div>
            </form>
        </div>

    </div>

</asp:Content>

